package com.penghaisoft.microwms.base.web.data.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.penghaisoft.microwms.base.web.data.service.IMdModelService;
import com.penghaisoft.microwms.base.web.data.service.IMdProModelService;
import com.penghaisoft.microwms.base.web.model.dao.MdModelMapper;
import com.penghaisoft.microwms.base.web.model.dao.MdProModelMapper;
import com.penghaisoft.microwms.common.data.model.MdModel;
import com.penghaisoft.microwms.common.data.model.MdProModel;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;


@Service("mdProModelService")
public class MdProModelServiceImpl extends BaseService implements IMdProModelService {
	@Resource
	private MdProModelMapper mdProModelMapper;
	/**
	   * 新增记录
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp create(MdProModel mdProModel){
			mdProModelMapper.create(mdProModel);
			return success();
		}

	  /**
	   * 删除记录（逻辑删除）
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp delete(MdProModel mdProModel){
			mdProModelMapper.delete(mdProModel);
			return success();
		}
		
	  /**
	   * 查询列表
	   * @param pager
	   * @param baseResource
	   * @return
	   */
		@Override
		public Pager<MdProModel> findListByCondition(int page, int rows,MdProModel condition){
		    Pager<MdProModel> pager = new Pager<>();
		    pager.setPage(page);
		    pager.setRows(rows);
  		condition.preQuery();
			List<MdProModel> records = mdProModelMapper.queryList(pager,condition);
			long size = mdProModelMapper.queryCount(condition);
			pager.setRecords(records);
			pager.setTotalCount(size);
			return pager;
		}

	  /**
	   * 查询单条
	   * @param id
	   * @return
	   */
		@Override
		public MdProModel findById(String id){
			return mdProModelMapper.queryById(id);
		}
		
	  /**
	   * 修改记录
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp update(MdProModel mdProModel){
			mdProModelMapper.updateBySelect(mdProModel);
			return success();
		}

}
